const app = getApp()
Page({
  data: {
    searchContent: '',
  },
  onCancel() {
    this.setData({
      inputValue: ''
    });
    wx.switchTab({
      url: '/pages/index/index',
    })
  },
  onSearch() {
    // 获取当前页面的搜索内容
    const searchContent = this.data.searchContent;
    
    wx.navigateTo({
      url: '/pages/index/searchResult/searchResult',
      events: {
        acceptDataFromOpenerPage(data) {
          console.log('收到来自目标页面的数据:', data);
        }
      },
      success: (res) => {
        // 通过事件通道发送 searchContent
        res.eventChannel.emit('acceptDataFromOpenerPage', {
          data: searchContent  // 传递实际数据
        });
      }
    });
  }
});